package com.hero.jobweb.action.personal;

import java.util.List;

import com.hero.jobweb.action.JobWebBaseAction;
import com.hero.jobweb.action.validator.JobWebValidator;
import com.hero.jobweb.entity.TbBasic;
import com.hero.jobweb.entity.TbResume;
import com.hero.jobweb.service.IResumeService;


/**
 * 简历管理Action
 * @author Volcano
 * 2011-06-11
 */
public class ResumeAction extends JobWebBaseAction implements JobWebValidator {

	private enum ResumeActionKey
	{
		SHOW_RESUME("show"),
		RESUME_MANAGE("manage"),
		WRITE("write"),
		WRITE_SUCCESS("write_success");
		private String value;
		private ResumeActionKey(String value)
		{
			this.value=value;
		}
		@Override
		public String toString() {
			return value;
		}
		
	}
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer rId;
	private IResumeService resumeService=(IResumeService) getBean("resumeServiceImpl");
	private IResumeService.FullResume fullResume=new IResumeService.FullResume();
	private List<TbResume> resumeList;

	public List<TbResume> getResumeList() {
		return resumeList;
	}

	public void setResumeList(List<TbResume> resumeList) {
		this.resumeList = resumeList;
	}

	public IResumeService.FullResume getFullResume() {
		return fullResume;
	}

	public void setFullResume(IResumeService.FullResume fullResume) {
		this.fullResume = fullResume;
	}

	public Integer getRId() {
		return rId;
	}

	public void setRId(Integer rId) {
		this.rId = rId;
	}
	
	
	
	/**
	 * 简历管理首页
	 * @return
	 */
	public String index()
	{
		//查询简历列表
		queryList();
		return ResumeActionKey.RESUME_MANAGE.toString();
	}
	
	/**
	 * 查询个人简历列表
	 * @return
	 */
	public String queryList()
	{
		TbResume tbResume=new TbResume();
		tbResume.setUserId(getPersonalUserId());
		resumeList=this.resumeService.queryResumeList(tbResume);
		return null;
	}
	/**
	 * 查询完整简历
	 * @return
	 */
	public String query()
	{
		TbResume tbResume=new TbResume();
		tbResume.setUserId(getPersonalUserId());
		tbResume.setId(rId);
		fullResume=resumeService.queryFullResumeByResumeId(tbResume);
		return ResumeActionKey.SHOW_RESUME.toString();
	}
	
	/**
	 * 写简历
	 * @return
	 */
	public String write()
	{
		TbBasic basic=new TbBasic();
		basic.setUserId(getPersonalUserId());
		basic.setEmail(getPersonalUser().getEmail());
		fullResume.setTbBasic(basic);
		fullResume=this.resumeService.write(fullResume);
		return ResumeActionKey.WRITE.toString();
	}
	/**
	 * 保存标准简历
	 * @return
	 */
	public String save()
	{
		TbBasic basic=fullResume.getTbBasic();
		basic.setUserId(getPersonalUserId());
		this.resumeService.saveStandardResume(fullResume);
		return ResumeActionKey.WRITE_SUCCESS.toString();
	}
	public void validatesave()
	{
		System.out.println("验证save");
	}
}
